package com.syni.mdd.yhd.common.all.dao.jpa;

import com.syni.mdd.yhd.common.all.dao.BaseJPADao;
import com.syni.mdd.yhd.common.all.entity.BmsUserVideoDk;
import com.syni.mdd.yhd.common.all.entity.BmsUserVideoLike;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface BmsUserVideoDkDao extends BaseJPADao<BmsUserVideoDk,Integer> {
    BmsUserVideoDk findByBmsUserIdAndBmsBusinessId(Integer userId, Integer businessId);

    List<BmsUserVideoDk> findByBmsUserId(Integer userId);

    @Query(value = "select bb.latitude,bb.longitude,bb.logo_url logoUrl from bms_user_video_dk buvd left join bms_business bb " +
            "on buvd.bms_business_id = bb.id where buvd.bms_user_id=?1 and bb.latitude is not null and bb.longitude is not null" +
            " and IF(?2 != '',bb.addr_city=?2,1=1)",nativeQuery = true)
    List<Map<String,Object>> selfFindByBmsUserId(Integer userId,String addrCity);


    @Query(value="select uk.id,uk.bms_business_id from bms_user_video_dk uk where uk.bms_user_id=?1",nativeQuery=true)
    List<Map<String,Object>> findByUserId(Integer userId);

    @Query(value = "select count(buvd.id) num,buvd.bms_user_id from bms_user_video_dk buvd where buvd.bms_user_id = ?1",nativeQuery = true)
    Map<String, Object> selfCountUserDkNum(Integer userId);


}
